<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Done</title>
</head>
<body>
  <p>Login successfully!</p>
  <p>This page will be closed after <span id="sec">5</span></p>
  <script type="module">
    const locEl = document.getElementById('loc');
    const secEl = document.getElementById('sec');
    
    let count = 5;
    function countDown() {
      document.getElementById('sec').innerText = count;
      if (count-- === 0) {
        localStorage.setItem('login', `${new Date()}`);
        window.close();
      }
      setTimeout(countDown, 1000);
    }
    setTimeout(countDown, 1000);
  </script>
</body>
</html>